package com.hzit.consumer.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.hzit.producer.entity.R;
import com.hzit.producer.entity.Student;
import com.hzit.producer.service.StudentService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 类名：
 * 作者：WF
 * 功能：
 */
@RestController
@RequestMapping("/student")
public class StudentController {

	//1. 从注册中心中取出接口为StudentService的类型的实现类
	@Reference(interfaceClass = StudentService.class,check = false,timeout = 15000,version = "1.0.0")
	private StudentService studentService;

	@GetMapping("/list")
	public R findAll(){
		List<Student> all = studentService.findAll();
		return R.ok().put("students",all);
	}

	@GetMapping("/findStudents")
	public R findStudents(String sname,String addr){
		System.out.println("sname = " + sname);
		System.out.println("addr = " + addr);
		List<Student> students = studentService.findStudents(sname,addr);
		return R.ok().put("students",students);
	}
}
